<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\MktUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '微信粉丝';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mkt-user-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?php if (YII_DEBUG) echo Html::a('创建', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php echo GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
			[
				'label' => 'ID',
                'attribute' => 'id',
                'filter' => false,
                'headerOptions' => array('style'=>'width:40px;'),           

			],

			[
				'label' => '头像',
				'format'=>'html',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->headimgurl))
                        return '';
                    $headimgurl = Html::img(\common\wosotech\Util::getWxUserHeadimgurl($model->headimgurl, 46), ['style'=>'width:46px;']);
                    return $headimgurl;
				},
			],
			[
				'label' => '姓名',
				'attribute' => 'name',
			],
//            'sex',
			[
				'label' => '性别',
				'attribute' => 'sex',
				'value'=>function ($model, $key, $index, $column) {  
						return $model->sex ? '男' : '女';
				},

			],

			[
				'label' => '微信昵称',
				'value'=>function ($model, $key, $index, $column) {  
						return empty($model->nickname) ? '' : $model->nickname;
					},
                'headerOptions' => array('style'=>'width:80px;'),           
			],

            //'status',
            [
                'label' => '状态',
                'attribute' => 'status',
                'value'=>function ($model, $key, $index, $column) { 
						return common\models\MktUser::getStatusOptions($model->status); 
					},
                'filter' => common\models\MktUser::getStatusOptions(),
                'headerOptions' => array('style'=>'width:80px;'),           
            ],

            //'industry_id',
			[
				'label' => '行业',
                'attribute' => 'industry_id',
				'value'=>function ($model, $key, $index, $column) {
                    if (empty($model->industry)) 
                        return '';
                    return $model->industry->getPaths('-');
				},
			],            

            //'area_id',
			[
				'label' => '区域',
				'value'=>function ($model, $key, $index, $column) {
                    if (empty($model->area)) 
                        return '';
                    return $model->area->getPaths('-');
				},
			],            

			[
				'label' => "金币",
                'format'=>'html',
				'value'=>function ($model, $key, $index, $column) {
                    if (empty($model->goldSum)) return '0';
				    return Html::a($model->goldSum, ['gold/index', 'user_id'=>$model->id]);
				},
                'headerOptions' => array('style'=>'width:40px;'),           
			],

			[
                'attribute' => 'mobile',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->mobile))
                        return '';
                    return $model->mobile;
				},
			],

			[
                'attribute' => 'email',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->email))
                        return '';
                    return $model->email;
				},
                'visible' => false
			],

			[
                'attribute' => 'qq',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->qq))
                        return '';
                    return $model->qq;
				},
                'visible' => false
			],

			[
                'attribute' => 'weixin_number',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->weixin_number))
                        return '';
                    return $model->weixin_number;
				},
                'visible' => false
			],

            //'name',
            // 'company',
            // 'duty',
            // 'password',
            // 'auth_key',
            // 'password_hash',
            // 'password_reset_token',
            // 'access_token',
            // 'disabled',
            // 'status',
            // 'create_time',
            // 'update_time',
            // 'openid',
            // 'unionid',
            // 'subscribe',
            // 'subscribe_time:datetime',
            // 'nickname',
            // 'sex',
            // 'city',
            // 'country',
            // 'province',
            // 'headimgurl:url',
            // 'on_message_post',
            // 'on_message_friend',
            // 'on_message_friend_log',
            // 'on_message_system',
            // 'on_quiet',
            // 'on_quiet_start_time',
            // 'on_quiet_end_time',
            // 'on_show_mobile',
            // 'on_show_qq',
            // 'on_show_weixin',
            // 'on_show_email:email',
			[
				'label' => "贴子",
                'format'=>'html',
				'value'=>function ($model, $key, $index, $column) {
                    $str = '';
                    if (!empty($model->postCount)) {
				        $str .= Html::a('贴子：' . $model->postCount, ['post/index', 'user_id'=>$model->id], ['title' => '贴子', 'class' => 'btn btn-xs btn-primary']);
                    }
                    return $str;
				},
                'headerOptions' => array('style'=>'width:70px;'),           
			],

			[
				'label' => "私信",
                'format'=>'html',
				'value'=>function ($model, $key, $index, $column) {
                    $str = '';
                    if (!empty($model->sendChatCount)) {
				        $str .= Html::a('发送：' . $model->sendChatCount, ['chat/send-list', 'user_id'=>$model->id], ['title' => '私信', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if (!empty($model->recvChatCount)) {
				        $str .= Html::a('接收：' . $model->recvChatCount, ['chat/recv-list', 'user_id'=>$model->id], ['title' => '私信', 'class' => 'btn btn-xs btn-primary']);
                    }
/*
                    if (!empty($model->responseCount)) {
				        $str .= Html::a('响应：' . $model->responseCount, ['response/index', 'user_id'=>$model->id], ['title' => '我的好友', 'class' => 'btn btn-xs btn-success']);
                    }
*/
                    return $str;
				},
                'headerOptions' => array('style'=>'width:70px;'),           
			],

			[
				'label' => "关注",
                'format'=>'html',
				'value'=>function ($model, $key, $index, $column) {
                    $str = '';
                    if (!empty($model->followCount)) {
				        $str .= Html::a('关注：' . $model->followCount, ['follow/index', 'user_id'=>$model->id], ['title' => '关注', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if (!empty($model->friendCount)) {
				        $str .= Html::a('好友：' . $model->friendCount, ['friend/index', 'user_id'=>$model->id], ['title' => '好友', 'class' => 'btn btn-xs btn-success']);
                    }
                    return $str;
				},
                'headerOptions' => array('style'=>'width:70px;'),           
			],

			[
				'label' => '资源',
                'format'=>'html',
                'headerOptions' => array('style'=>'width:80px;'),           
				'value'=>function ($model, $key, $index, $column) {
                    $str = '';
                    if ($model->getSourceMemberCount()) {
					    $str .= Html::a('会员：' . $model->getSourceMemberCount(), ['source-member/index', 'user_id'=>$model->id], ['title' => '会员', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if ($model->getSourceRoomCount()) {
                        $str .= Html::a('场地：' . $model->getSourceRoomCount(), ['source-room/index', 'user_id'=>$model->id], ['title' => '场地', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if ($model->getSourceGiftCount()) {
                        $str .= Html::a('礼品' . $model->getSourceGiftCount(), ['source-gift/index', 'user_id'=>$model->id], ['title' => '礼品', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if ($model->getSourcePromotionCount()) {
                        $str .= Html::a('推广' . $model->getSourcePromotionCount(), ['source-promotion/index', 'user_id'=>$model->id], ['title' => '推广', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if ($model->getSourceDonateCount()) {
                        $str .= Html::a('赞助' . $model->getSourceDonateCount(), ['source-donate/index', 'user_id'=>$model->id], ['title' => '赞助', 'class' => 'btn btn-xs btn-primary']);
                    }
                    if ($model->getSourceServiceCount()) {
                        $str .= Html::a('服务：' . $model->getSourceServiceCount(), ['source-service/index', 'user_id'=>$model->id], ['title' => '服务', 'class' => 'btn btn-xs btn-primary']);
                    }
                    return $str;
				},
			],
            
            [   'class' => 'yii\grid\ActionColumn',
                'headerOptions' => array('style'=>'width:80px;'),           
            ],

        ],
    ]); ?>

</div>
